﻿using ProductionLine.Infrastructure.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace ProductionLine.Infrastructure.Implement
{
    public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
    {
        private readonly ProductionLineDbContext db;

        public BaseRepository(ProductionLineDbContext db)
        {
            this.db = db;
        }

        public IQueryable<T> GetAll()
        {
            return db.Set<T>();
        }

        public IQueryable<T> GetAllAsync(Expression<Func<T, bool>> expression)
        {
            return db.Set<T>().Where(expression).AsQueryable();
        }
    }
}
